﻿using System;
using System.Data;
using System.Collections.Generic;
using SERP.DAO;
namespace SERP.Controllers{
public class OrganizationsControllerBase : Controller{
	public OrganizationsControllerBase()
		: base()
	{
	}
	private static OrganizationsDAO _Service; 
	public static OrganizationsDAO Service{
		get{
			if(_Service==null)
				_Service = new OrganizationsDAO();
			return _Service;
		}
		set{
			_Service = value;
		}
	}
    //Copy data from data row in grid to object
    public OrganizationsEntity MapDataRowToObject(DataRow row){
		OrganizationsEntity o = new OrganizationsEntity();
		 o.OrgCode=Convert.ToString(row["OrgCode"]);
		 o.OrgName=Convert.ToString(row["OrgName"]);
		 o.Note=Convert.ToString(row["Note"]);
		 if(!row.IsNull("OrgType"))
			o.OrgType=ConvertByte(row["OrgType"]);
		 if(!row.IsNull("ParentId"))
			o.ParentId=(Int32)(row["ParentId"]);
		 if(!row.IsNull("OrganizationId"))
		    o.OrganizationId=(Int32)(row["OrganizationId"]);
		 return o;
    }
	//Copy data from object to data row in grid    
    public void MapObjectToDataRow(OrganizationsEntity o,DataRow row){
		row["OrgCode"]=o.OrgCode;
		row["OrgName"]=o.OrgName;
		row["Note"]=o.Note;
		row["OrgType"]=o.OrgType;
		row["ParentId"]=o.ParentId;
		row["OrganizationId"]=o.OrganizationId;
    }
}
}
